<template>
<view class="ag_box">
  <rich-text :nodes="ag_info"></rich-text>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
      ag_info: ''
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this,
        ty = options.ty;

    if (ty == 1) {
      wx.setNavigationBarTitle({
        title: '会员协议'
      });
    } else {
      wx.setNavigationBarTitle({
        title: '会员权益'
      });
    }

    that.getInfo(ty);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    //获取协议信息
    getInfo: function (e) {
      var that = this;
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "home.index.vip_treaty"
        },
        success: function (res) {
          console.log('会员协议返回：', res.data);

          if (e == 1) {
            that.setData({
              ag_info: res.data.data.vip_treaty
            });
          } else {
            that.setData({
              ag_info: res.data.data.vip_equity
            });
          }
        },
        fail: function (res) {}
      });
    }
  }
};
</script>
<style>
@import "./agInfo.css";
</style>